#pragma once

namespace DABG {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	public ref class frmOptions : public System::Windows::Forms::Form
	{
	public:
		frmOptions(Account ^acc)
		{
			accPointer = acc;
			InitializeComponent();
		}

	protected:
		~frmOptions()
		{
			if (components)
			{
				delete components;
			}
		}

	protected: 


	private: System::Windows::Forms::Label^  lblInfo2;
	private: System::Windows::Forms::Label^  lblInfo1;

	private: System::Windows::Forms::Label^  label4;
	private: System::Windows::Forms::TextBox^  txtRiskPerTrade;
	private: System::Windows::Forms::Label^  label5;
	private: System::Windows::Forms::TextBox^  txtRiskPerDay;



	private: System::Windows::Forms::Button^  btnApply;



	private: System::Windows::Forms::ToolTip^  toolTip1;
	private: System::Windows::Forms::CheckBox^  ckUseAdvisor;
	private: System::Windows::Forms::Label^  label1;
	private: System::Windows::Forms::TextBox^  txtAllocation;
	private: System::Windows::Forms::Label^  lblInfo3;
	private: System::Windows::Forms::ComboBox^  cbSubAcc;
	private: System::Windows::Forms::Label^  label2;
	private: System::Windows::Forms::Label^  lblInfo4;
	private: System::Windows::Forms::GroupBox^  groupBox1;
	private: System::Windows::Forms::Button^  btnRestore;
	private: System::ComponentModel::IContainer^  components;

	private:


#pragma region Windows Form Designer generated code
		void InitializeComponent(void)
		{
			this->components = (gcnew System::ComponentModel::Container());
			this->lblInfo2 = (gcnew System::Windows::Forms::Label());
			this->lblInfo1 = (gcnew System::Windows::Forms::Label());
			this->label4 = (gcnew System::Windows::Forms::Label());
			this->txtRiskPerTrade = (gcnew System::Windows::Forms::TextBox());
			this->label5 = (gcnew System::Windows::Forms::Label());
			this->txtRiskPerDay = (gcnew System::Windows::Forms::TextBox());
			this->btnApply = (gcnew System::Windows::Forms::Button());
			this->toolTip1 = (gcnew System::Windows::Forms::ToolTip(this->components));
			this->ckUseAdvisor = (gcnew System::Windows::Forms::CheckBox());
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->txtAllocation = (gcnew System::Windows::Forms::TextBox());
			this->lblInfo3 = (gcnew System::Windows::Forms::Label());
			this->cbSubAcc = (gcnew System::Windows::Forms::ComboBox());
			this->label2 = (gcnew System::Windows::Forms::Label());
			this->lblInfo4 = (gcnew System::Windows::Forms::Label());
			this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
			this->btnRestore = (gcnew System::Windows::Forms::Button());
			this->groupBox1->SuspendLayout();
			this->SuspendLayout();
			// 
			// lblInfo2
			// 
			this->lblInfo2->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
			this->lblInfo2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->lblInfo2->Location = System::Drawing::Point(186, 41);
			this->lblInfo2->Name = L"lblInfo2";
			this->lblInfo2->Size = System::Drawing::Size(18, 19);
			this->lblInfo2->TabIndex = 13;
			this->lblInfo2->Text = L"\?";
			// 
			// lblInfo1
			// 
			this->lblInfo1->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
			this->lblInfo1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->lblInfo1->Location = System::Drawing::Point(186, 18);
			this->lblInfo1->Name = L"lblInfo1";
			this->lblInfo1->Size = System::Drawing::Size(18, 19);
			this->lblInfo1->TabIndex = 13;
			this->lblInfo1->Text = L"\?";
			// 
			// label4
			// 
			this->label4->AutoSize = true;
			this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->label4->Location = System::Drawing::Point(22, 18);
			this->label4->Name = L"label4";
			this->label4->Size = System::Drawing::Size(102, 16);
			this->label4->TabIndex = 9;
			this->label4->Text = L"Risk Per Trade:";
			// 
			// txtRiskPerTrade
			// 
			this->txtRiskPerTrade->Location = System::Drawing::Point(130, 17);
			this->txtRiskPerTrade->Name = L"txtRiskPerTrade";
			this->txtRiskPerTrade->Size = System::Drawing::Size(50, 20);
			this->txtRiskPerTrade->TabIndex = 10;
			this->txtRiskPerTrade->TabStop = false;
			// 
			// label5
			// 
			this->label5->AutoSize = true;
			this->label5->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->label5->Location = System::Drawing::Point(22, 41);
			this->label5->Name = L"label5";
			this->label5->Size = System::Drawing::Size(90, 16);
			this->label5->TabIndex = 9;
			this->label5->Text = L"Risk Per Day:";
			// 
			// txtRiskPerDay
			// 
			this->txtRiskPerDay->Location = System::Drawing::Point(118, 40);
			this->txtRiskPerDay->Name = L"txtRiskPerDay";
			this->txtRiskPerDay->Size = System::Drawing::Size(62, 20);
			this->txtRiskPerDay->TabIndex = 10;
			this->txtRiskPerDay->TabStop = false;
			// 
			// btnApply
			// 
			this->btnApply->BackColor = System::Drawing::SystemColors::Control;
			this->btnApply->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->btnApply->Location = System::Drawing::Point(12, 202);
			this->btnApply->Name = L"btnApply";
			this->btnApply->Size = System::Drawing::Size(76, 40);
			this->btnApply->TabIndex = 8;
			this->btnApply->TabStop = false;
			this->btnApply->Text = L"OK";
			this->btnApply->UseVisualStyleBackColor = false;
			this->btnApply->Click += gcnew System::EventHandler(this, &frmOptions::btnApply_Click);
			// 
			// toolTip1
			// 
			this->toolTip1->AutomaticDelay = 0;
			this->toolTip1->IsBalloon = true;
			this->toolTip1->ShowAlways = true;
			this->toolTip1->ToolTipIcon = System::Windows::Forms::ToolTipIcon::Info;
			this->toolTip1->ToolTipTitle = L"Info";
			// 
			// ckUseAdvisor
			// 
			this->ckUseAdvisor->AutoSize = true;
			this->ckUseAdvisor->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->ckUseAdvisor->Location = System::Drawing::Point(12, 19);
			this->ckUseAdvisor->Name = L"ckUseAdvisor";
			this->ckUseAdvisor->Size = System::Drawing::Size(159, 20);
			this->ckUseAdvisor->TabIndex = 14;
			this->ckUseAdvisor->Text = L"Use Advisor Account\?";
			this->ckUseAdvisor->UseVisualStyleBackColor = true;
			this->ckUseAdvisor->CheckedChanged += gcnew System::EventHandler(this, &frmOptions::ckUseAdvisor_CheckedChanged);
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->label1->Location = System::Drawing::Point(9, 42);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(70, 16);
			this->label1->TabIndex = 9;
			this->label1->Text = L"Allocation:";
			// 
			// txtAllocation
			// 
			this->txtAllocation->Enabled = false;
			this->txtAllocation->Location = System::Drawing::Point(85, 41);
			this->txtAllocation->Name = L"txtAllocation";
			this->txtAllocation->Size = System::Drawing::Size(83, 20);
			this->txtAllocation->TabIndex = 10;
			this->txtAllocation->TabStop = false;
			this->txtAllocation->Text = L"All";
			// 
			// lblInfo3
			// 
			this->lblInfo3->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
			this->lblInfo3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->lblInfo3->Location = System::Drawing::Point(174, 43);
			this->lblInfo3->Name = L"lblInfo3";
			this->lblInfo3->Size = System::Drawing::Size(18, 19);
			this->lblInfo3->TabIndex = 13;
			this->lblInfo3->Text = L"\?";
			// 
			// cbSubAcc
			// 
			this->cbSubAcc->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
			this->cbSubAcc->Enabled = false;
			this->cbSubAcc->FormattingEnabled = true;
			this->cbSubAcc->Items->AddRange(gcnew cli::array< System::Object^  >(20) {L"1", L"2", L"3", L"4", L"5", L"6", L"7", L"8", 
				L"9", L"10", L"11", L"12", L"13", L"14", L"15", L"16", L"17", L"18", L"19", L"20"});
			this->cbSubAcc->Location = System::Drawing::Point(12, 88);
			this->cbSubAcc->Name = L"cbSubAcc";
			this->cbSubAcc->Size = System::Drawing::Size(156, 21);
			this->cbSubAcc->TabIndex = 15;
			// 
			// label2
			// 
			this->label2->AutoSize = true;
			this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->label2->Location = System::Drawing::Point(9, 69);
			this->label2->Name = L"label2";
			this->label2->Size = System::Drawing::Size(155, 16);
			this->label2->TabIndex = 9;
			this->label2->Text = L"How Much SubAccounts:";
			// 
			// lblInfo4
			// 
			this->lblInfo4->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
			this->lblInfo4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->lblInfo4->Location = System::Drawing::Point(174, 81);
			this->lblInfo4->Name = L"lblInfo4";
			this->lblInfo4->Size = System::Drawing::Size(18, 19);
			this->lblInfo4->TabIndex = 13;
			this->lblInfo4->Text = L"\?";
			// 
			// groupBox1
			// 
			this->groupBox1->Controls->Add(this->lblInfo4);
			this->groupBox1->Controls->Add(this->ckUseAdvisor);
			this->groupBox1->Controls->Add(this->cbSubAcc);
			this->groupBox1->Controls->Add(this->txtAllocation);
			this->groupBox1->Controls->Add(this->label2);
			this->groupBox1->Controls->Add(this->label1);
			this->groupBox1->Controls->Add(this->lblInfo3);
			this->groupBox1->Location = System::Drawing::Point(12, 76);
			this->groupBox1->Name = L"groupBox1";
			this->groupBox1->Size = System::Drawing::Size(201, 120);
			this->groupBox1->TabIndex = 16;
			this->groupBox1->TabStop = false;
			this->groupBox1->Text = L"Advisor Account";
			// 
			// btnRestore
			// 
			this->btnRestore->BackColor = System::Drawing::SystemColors::Control;
			this->btnRestore->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->btnRestore->Location = System::Drawing::Point(118, 202);
			this->btnRestore->Name = L"btnRestore";
			this->btnRestore->Size = System::Drawing::Size(95, 40);
			this->btnRestore->TabIndex = 8;
			this->btnRestore->TabStop = false;
			this->btnRestore->Text = L"Restore To Default";
			this->btnRestore->UseVisualStyleBackColor = false;
			this->btnRestore->Click += gcnew System::EventHandler(this, &frmOptions::btnRestore_Click);
			// 
			// frmOptions
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(225, 247);
			this->Controls->Add(this->groupBox1);
			this->Controls->Add(this->label4);
			this->Controls->Add(this->lblInfo2);
			this->Controls->Add(this->lblInfo1);
			this->Controls->Add(this->btnRestore);
			this->Controls->Add(this->btnApply);
			this->Controls->Add(this->txtRiskPerTrade);
			this->Controls->Add(this->label5);
			this->Controls->Add(this->txtRiskPerDay);
			this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedToolWindow;
			this->Name = L"frmOptions";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
			this->Text = L"Options";
			this->Load += gcnew System::EventHandler(this, &frmOptions::frmOptions_Load);
			this->groupBox1->ResumeLayout(false);
			this->groupBox1->PerformLayout();
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion

	Account ^accPointer;

	private: System::Void frmOptions_Load(System::Object^  sender, System::EventArgs^  e)
			 {
				 txtRiskPerDay->Text = Convert::ToString(accPointer->RiskPerDay);
				 txtRiskPerTrade->Text = Convert::ToString(accPointer->RiskInDollar);
				 txtAllocation->Text = accPointer->Allocation;
				 cbSubAcc->Text = Convert::ToString(accPointer->SubAcc);
				 if (accPointer->UseAdvisorAcc == true) ckUseAdvisor->Checked = true;

				 toolTip1->SetToolTip(lblInfo1, "Max ($) amount risked per trade");
				 toolTip1->SetToolTip(lblInfo2, "Max loss ($) per day");
				 toolTip1->SetToolTip(lblInfo3, "Name of Allocation Group in Advisor Account");
				 toolTip1->SetToolTip(lblInfo4, "Number of the accounts in the Advisor Group");
				 toolTip1->Active;
			 }

	private: System::Void btnApply_Click(System::Object^  sender, System::EventArgs^  e)
			 {
				 AccountRegularOptions ^acc_opt = gcnew AccountRegularOptions;
				 AccountStrategy1Options ^strg_opt = gcnew AccountStrategy1Options;

				 acc_opt->optRiskPerDay = Convert::ToDouble(txtRiskPerDay->Text);
				 acc_opt->optRiskPerTrade = Convert::ToDouble(txtRiskPerTrade->Text);
				 acc_opt->optUseAdvisorAcc = ckUseAdvisor->Checked;
				 acc_opt->optAllocation = txtAllocation->Text;
				 acc_opt->optSubAcc = Convert::ToInt16(cbSubAcc->Text);

				 accPointer->ChangeAccountOptParameters(acc_opt);
				 Close();
			 }

	private: System::Void ckUseAdvisor_CheckedChanged(System::Object^  sender, System::EventArgs^  e)
			 {
				 if (ckUseAdvisor->Checked == true)
				 {
					 txtAllocation->Enabled = true;
					 cbSubAcc->Enabled = true;
				 }
				 else
				 {
					 txtAllocation->Enabled = false;
					 cbSubAcc->Enabled = false;
				 }
			 }

	private: System::Void btnRestore_Click(System::Object^  sender, System::EventArgs^  e)
			 {
				 MessageBoxButtons buttons = MessageBoxButtons::YesNo;
				 System::Windows::Forms::DialogResult result;

				 result = MessageBox::Show(this, "Are you sure you want to restore all settings to the default?\nYou'll need to reopen the software if press yes!", "Restore To Default Settings", buttons);
				 if (result == ::DialogResult::No) return;

				 MessageBox::Show("The program will be close now");
				 remove("Data.txt");
				 exit(1);
			 }
};
}
